<template>
    <transition name="com-fade">
        <div :class="['notice']"
             v-show="state"
             @click.self="$emit('cancel','mask')">
            <transition name="com-move">
                <div class="box"
                     v-show="state"
                     :style="[{paddingTop:!title? '2.4rem' : 0 },containerStyle]">
                    <div class="title"
                         :style="{textAlign:titleAlign}"
                         v-if="title">{{title}}</div>
                    <div class="content">
                        <div :style="[{textAlign:slotAlign},{width:'100%'}]">
                            <slot>...</slot>
                        </div>
                    </div>
                    <BaseButtons :confirmText="btnName[1]"
                                 :cancelText="btnName[0]"
                                 :cancelTextColor="cancelTextColor"
                                 :confirmTextColor="confirmTextColor"
                                 :cancelShow="cancelShow"
                                 @cancel="cancel"
                                 @submit="submit" />
                </div>
            </transition>
        </div>
    </transition>
</template>

<script>
import { mapState } from 'vuex';
export default {
    props: {
        title: String,
        btnName: {
            default() {
                return [this.$t('cancel'), this.$t('confirm')];
            },
            type: Array
        },
        cancelTextColor: String,
        confirmTextColor: String,
        cancelShow: {
            default: true,
            type: Boolean
        },
        titleAlign: String, // 标题对齐方式
        slotAlign: String, // 插槽文字对齐方式
        state: {
            default: false,
            type: Boolean
        }
    },
    methods: {
        cancel() {
            this.$emit('cancel');
        },
        submit() {
            this.$emit('confirm');
        }
    },
    computed: {
        containerStyle() {
            return {
                    position: 'absolute',
                    left: 'var(--emui_dimens_dialog_start)',
                    right: 'var(--emui_dimens_dialog_end)',
                    bottom: 'var(--emui_dimens_dialog_bottom)'
                };
        }
    },
    mounted () {
        
    }
};
</script>

<style lang="less" scoped>
@import url("../style/public.less");
.notice {
    width: 100%;
    
    z-index: 99;
    .mask();
    .fade();
    &.spread {
        display: flex;
        justify-content: center;
        align-items: center;
    }
    .box {
        border-radius: var(--emui_corner_radius_xlarge);
        background-color: var(--emui_popup_bg);
        z-index: 11;
        // .move();
        .title {
            height: 5.6rem;
            padding: 0 2.4rem;
            font-size: 2rem;
            line-height: 5.6rem;
            color: var(--emui_text_primary);
            .medium();
        }
        .content {
            min-height: 4.8rem;
            padding: 0 0.8rem 0.8rem;
            font-size: 1.6rem;
            color: var(--emui_text_primary);
            display: flex;
            align-items: center;
            justify-content: center;
        }
    }
}
</style>
